package Adapt.Motor;
interface Motor{
    public void drive();
}
//适配者1：电能发动机
class ElectricMotor{
    public void electricDrive(){
        System.out.println("电能发动机适配者");
    }
}
//适配者2：光能发动机
class OpticalMotor{
    public void opticalDrive(){
        System.out.println("光能发动机适配者类");
    }
}
//电能适配器
class ElectricAdaptor implements Motor{
    private ElectricMotor electricMotor;
    public ElectricAdaptor(){
        electricMotor = new ElectricMotor();
    }
    @Override
    public void drive() {
        electricMotor.electricDrive();
    }
}
//光能适配器
class OpticalAdapter implements Motor{
    private OpticalMotor opticalMotor;
    public OpticalAdapter(){
        opticalMotor = new OpticalMotor();
    }
    @Override
    public void drive() {
        opticalMotor.opticalDrive();
    }
}
public class MotorAdapterTest {
    public static void main(String[] args) {
        System.out.println("适配器模式测试：");
        Motor motor = new OpticalAdapter();
        motor.drive();
    }
}
